Skip to content

Improve code styling-quality and migrate to GitHub actions - #24

Merged
CoMPaTech merged 28 commits into
mainfrom
quality
Oct 31, 2020
Merged

CoMPaTech merged 28 commits into
mainfrom
quality

Conversation

@CoMPaTech

@CoMPaTech CoMPaTech commented Oct 28, 2020 •

Copy link
Copy Markdown
Member

Codespell fixes
Flake8 improvements

  • Some todo's on complexity => todo for [IMPROVE] Solve complexity #28
  • Lots of == True, == False and != None corrected (but they should be evaluated to be 'if cond:' instead of 'if cond is True' probably => todo for [IMPROVE] If statements for booleans/trilean state #27
  • Make github actions validate commits (like pre-commit already does, but force it)
  • Make github action test the code and do codecov
  • Switch from Travis doing pypi and testing to Github Actions

Added Github actions to replace Travis - I did not include ad Github action for the PyPi publishing yet, first build some experience with github actions (it does do codecov though, so we'll have to take that out of travis eventually).

Travis is switching everything from .org to .com check this and having everything in github seems doable.

If we merge this we switch to Github actions and travis is being disabled (for now). See the 'Checks' tab at the top for everything that happens!

@codecov

codecov Bot commented Oct 28, 2020 •

Copy link
Copy Markdown

Codecov Report

Merging #24 into main will not change coverage.
The diff coverage is 75.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main      #24   +/-   ##
=======================================
  Coverage   93.69%   93.69%           
=======================================
  Files           5        5           
  Lines        1506     1506           
=======================================
  Hits         1411     1411           
  Misses         95       95           
Impacted Files Coverage Δ
plugwise/constants.py 100.00% <ø> (ø)
setup.py 0.00% <0.00%> (ø)
plugwise/smile.py 91.39% <100.00%> (ø)
tests/test_smile.py 97.61% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9e3809d...689b132. Read the comment docs.

@CoMPaTech CoMPaTech added the enhancement New feature or request label Oct 28, 2020
@CoMPaTech

CoMPaTech commented Oct 29, 2020 •

Copy link
Copy Markdown
Member Author

Works (https://test.pypi.org/project/plugwise/#history) => 0.8.2a0

Obviously we won't know of PyPi itself works unless we merge, but let's first thoroughly review :)

@CoMPaTech
CoMPaTech marked this pull request as ready for review October 29, 2020 11:24
@bouwew

bouwew commented Oct 29, 2020

Copy link
Copy Markdown
Contributor

Yes correct, if x is True should become if x, if x is False should become if not x.

And to be honest, there must be bugs in black. Look at const.py, at my latest attempt it made all SMILES-entries 1-liners, now it is changed back to multi-liner except for the last 2 ?!

@CoMPaTech

Copy link
Copy Markdown
Member Author

Yeah, that was on my list of things, also isort is acting weird or something else is acting up on plugwise/parser.py

@bouwew

bouwew commented Oct 30, 2020

Copy link
Copy Markdown
Contributor

I see print() commands in several places in the stick-code, should we replace these by _LOGGER.debug() commands?

@CoMPaTech

Copy link
Copy Markdown
Member Author

I see print() commands in several places in the stick-code, should we replace these by _LOGGER.debug() commands?

                  if self.print_progress:
                      print("Scan Plugwise network")
                  self.scan(callback)

Apparently they are part of of the self.print_progress variable of the stick class. I guess they should be debug indeed. @brefra?

@CoMPaTech
CoMPaTech requested a review from bouwew October 30, 2020 13:04
@CoMPaTech
CoMPaTech requested a review from brefra October 30, 2020 13:04
@bouwew

bouwew commented Oct 30, 2020 •

Copy link
Copy Markdown
Contributor

And we should replace all _LOGGER_debug("... %s ...", var), _LOGGER_debug("... %s ... %s ...", (var1, var2)) by _LOGGER_debug(f"... {var} ..."), LOGGER_debug(f"... {var1}... {var2} ...")

@CoMPaTech

Copy link
Copy Markdown
Member Author

And we should replace all _LOGGER_debug("... %s ...", var), _LOGGER_debug("... %s ... %s ...", (var1, var2)) by _LOGGER_debug(f"... {var} ..."), LOGGER_debug(f"... {var1}... {var2} ...")

Good call, but maybe we should have a look at the vast amount of them and if we can't make that smarter

# _LOGGER.debug statements
  10 node.py
  14 parser.py
   3 smile.py
  47 stick.py

Constructions like

                            _LOGGER.info(
                                "Resend %s for %s because stick did not acknowledge request (%s), last seq_id=%s",
                                str(
                                    self.expected_responses[seq_id][
                                        1
                                    ].__class__.__name__
                                ),
                                mac,
                                str(seq_id),
                                str(self.last_ack_seq_id),
                            )

won't make it more readable (pointing at the str self expected response part). And I see some of them even with calculations in those fields

@bouwew

bouwew commented Oct 30, 2020

Copy link
Copy Markdown
Contributor

Smarter and/or less debugging? But that is mostly for @brefra to judge.

@CoMPaTech

Copy link
Copy Markdown
Member Author

Created 3 [IMPROVE] issues for the separate improvements, also renamed this PR to clarify it's about code styling quality and github actions, aiming to keep (this) PR(s) as small as possible.

@CoMPaTech CoMPaTech changed the title Improve quality and prepare for GitHub actions Improve code styling-quality and migrate to GitHub actions Oct 30, 2020
@CoMPaTech

Copy link
Copy Markdown
Member Author

Latest commit adds code security scanning as per https://github.com/plugwise/python-plugwise/security/code-scanning

@bouwew bouwew left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestions:

  • change all if something is True: to if something:
  • change all if something is False: to if not something:

@CoMPaTech

Copy link
Copy Markdown
Member Author

We can, but let's do that in #30 then (crc is already checked off in that one)

@bouwew bouwew left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking out loud here: what's the difference between #24 and #30? Very difficult to judge with all the many changes :)

Any, please go ahead, I'll review again when #30 is ready for review, after #24 has been merged.

@CoMPaTech

Copy link
Copy Markdown
Member Author

I'm thinking out loud here: what's the difference between #24 and #30? Very difficult to judge with all the many changes :)

Any, please go ahead, I'll review again when #30 is ready for review, after #24 has been merged.

Hence the heads-up in discord that #30 was build upon #24 ... so to first get #24 out of the way.

@CoMPaTech
CoMPaTech merged commit 80438dd into main Oct 31, 2020
@CoMPaTech
CoMPaTech deleted the quality branch October 31, 2020 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants